package com.topfinance.payment.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.topfinance.frame.dao.HibernateEntityDao;
import com.topfinance.frame.exception.AppException;
import com.topfinance.frame.util.StringUtil;
import com.topfinance.payment.ebo.TCfgFmt8583Ebo;
import com.topfinance.payment.ebo.TCfgFormatEbo;
import com.topfinance.payment.service.ITCfgFmt8583Mgr;

/**
 * 该类自动实现了dao的一般方法，如add, remove, update
 * 在service中出现的大部分情况下是在向后台提交数据前的处理(如校验)及获取后台数据后的处理等
 * 
 * @author
 * 
 */

public class TCfgFmt8583MgrImpl extends HibernateEntityDao<TCfgFmt8583Ebo> implements ITCfgFmt8583Mgr {

	private static final Log log = LogFactory.getLog(TCfgFmt8583MgrImpl.class);

	// 获得传输协议
	public TCfgFmt8583Ebo getTC2Fmt8583(Integer oid) throws AppException {
		return (TCfgFmt8583Ebo) get(oid);
	}

	public void deleteTC2Fmt8583(Integer oid) throws AppException {
		removeById(TCfgFmt8583Ebo.class, oid);
	}

	// 获得8583格式明细
	public List<TCfgFmt8583Ebo> getAllFmt8583(Integer fmtOId, String fmtName) throws AppException {
		String hql = " from TCfgFmt8583Ebo t ";
		String where = "";
		if (fmtOId != null && fmtOId.intValue() > 0)
			where += " and t.TCfgFormat.oid = " + fmtOId;
		if (StringUtil.isNotNullStr(fmtName))
			where += " and t.TCfgFormat.name = '" + fmtName + "'";
		List<Object> paramList = new ArrayList<Object>();
		if (isNotBlank(where)) {
			where = " where " + where.substring(4);
		}
		hql = hql + where;
		return find(hql, paramList.toArray());
	}

}
